package com.filter;

import com.entity.Poker;

import java.util.List;

/**
 * 序列化牌面过滤
 * 牌面数字为连号
 */
public class SerialNumberGroupFilter extends BaseGroupFilter {
    public SerialNumberGroupFilter(List<Poker> pokers) {
        super(pokers);
    }

    @Override
    protected boolean filterHandler() {
        int flag = 0;
        int preNum = 0;
        for (Poker poker : pokers) {
            if (flag == 0) {
                preNum = poker.getNum();
            } else {
                if (poker.getNum() - 1 != preNum) {
                    return false;
                }
                preNum = poker.getNum();
            }
            flag++;
        }
        return true;
    }
}
